<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:insert="~{include :: header('修改配置信息')}" />
    <style>
        .form-group span{
            color: red;
        }
    </style>
</head>
<body>
<div class="container-fluid mt-2 mb-2">
    <div class="card card-primary card-outline card-outline-tabs mb-0">
        <div class="card-header p-0 border-bottom-0">
            <ul class="nav nav-tabs">
                <li class="nav-item">
                    <a class="nav-link" href="/profile/edit.html?type=serviceSwitch">功能开关</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/profile/edit.html?type=register">注册开关</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active" href="/profile/edit.html?type=invite">分销配置</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/profile/edit.html?type=baiJiaYun">百家云</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/profile/edit.html?type=tencentCloud">腾讯云</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/profile/edit.html?type=aliyun">阿里云</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/profile/edit.html?type=genseeLive">展示互动直播</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/profile/edit.html?type=sensitiveWords">敏感词</a>
                </li>
            </ul>
        </div>
        <div class="card-body">
            <form class="form-horizontal m" id="form-profile-edit">
                <input id="modelType"  th:value="${modelType}" type="hidden"/>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label text-sm-right">课程分成比例(<span>%</span>)</label>
                    <div class="col-sm-2">
                        <input id="rateCourse" name="rateCourse" th:value="${websiteProfile.get('rateCourse')}" class="form-control" type="text">
                    </div>
                    <div class="col-sm-8 form-control-static"><span>（创作者的课程销售可得到的分成比例）</span></div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label text-sm-right">直播分成比例(<span>%</span>)</label>
                    <div class="col-sm-2">
                        <input id="rateLive" name="rateLive" th:value="${websiteProfile.get('rateLive')}" class="form-control" type="text">
                    </div>
                    <div class="col-sm-8 form-control-static">
                        <span>（创作者的直播销售可得到的分成比例）</span>
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label text-sm-right">合伙人分成比例(<span>%</span>)</label>
                    <div class="col-sm-2">
                        <input id="ratePartner" name="ratePartner" th:value="${websiteProfile.get('ratePartner')}" class="form-control" type="text">
                    </div>
                    <div class="col-sm-8 form-control-static">
                        <span>（合伙人或组织者直接销售的分成比例）</span>
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label text-sm-right">代理分成比例(<span>%</span>)</label>
                    <div class="col-sm-2">
                        <input id="rateAgent" name="rateAgent" th:value="${websiteProfile.get('rateAgent')}" class="form-control" type="text">
                    </div>
                    <div class="col-sm-8 form-control-static">
                        <span>（当销售存在用户分享提成时，合伙人或组织者拿代理分成）</span>
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label text-sm-right">分享课程销售提成比例(<span>%</span>)</label>
                    <div class="col-sm-2">
                        <input id="rateSeller" name="rateSeller" th:value="${websiteProfile.get('rateSeller')}" class="form-control" type="text">
                    </div>
                    <div class="col-sm-8 form-control-static">
                        <span>（用户或分享者直接销售的提成比例）</span>
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label text-sm-right">邀请购买会员提成比例(<span>%</span>)</label>
                    <div class="col-sm-2">
                        <input id="rateMember" name="rateMember" th:value="${websiteProfile.get('rateMember')}" class="form-control" type="text">
                    </div>
                    <div class="col-sm-8 form-control-static">
                        <span>（邀请用户购买会员返现给用户的比例）</span>
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label text-sm-right">邀请注册用户返现(<span>分</span>)</label>
                    <div class="col-sm-2">
                        <input id="regCashback" name="regCashback" th:value="${websiteProfile.get('regCashback')}" class="form-control" type="text">
                    </div>
                    <div class="col-sm-8 form-control-static">
                        <span>（邀请注册成功后返现给邀请者金额，0为不返现）</span>
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label text-sm-right">是否启用分销功能</label>
                    <div class="col-sm-2">
                        <select name="enabled" id="enabled" class="form-control m-b">
                            <option value="ON" th:checked="${websiteProfile.get('enabled')=='ON'}">ON</option>
                            <option value="OFF" th:checked="${websiteProfile.get('enabled')=='OFF'}">OFF</option>
                        </select>
                    </div>
                    <div class="col-sm-8 form-control-static">
                        <span>（分销返现金额是否允许提现到银行卡）</span>
                    </div>
                </div>
                <div class="form-group row">
                    <label class="col-sm-2"></label>
                    <div class="col-sm-6">
                        <button type="button" class="btn btn-primary" onclick="inviteSave()"><i class="fa fa-check"></i>保 存</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<th:block th:insert="~{include :: footer}" />
<script src="/static/js/profile.js"></script>
<script>

    function inviteSave() {
        var rateCourse = $('#rateCourse').val();
        var rateLive = $('#rateLive').val();
        var ratePartner = $('#ratePartner').val();
        var rateAgent = $('#rateAgent').val();
        var rateSeller = $('#rateSeller').val();
        var regCashback = $('#regCashback').val();
        var rateMember = $('#rateMember').val();
        if (isNaN(rateCourse)) {
            return layer.msg('课程分成比例必需为数字！', {icon: 2});
        }
        if (parseInt(rateCourse) > 50 || parseInt(rateCourse) < 0) {
            return layer.msg('课程分成比例设置错误，不能大于50或小于0！', {icon: 2});
        }
        if (isNaN(rateLive)) {
            return layer.msg('直播分成比例必需为数字！', {icon: 2});
        }
        if (parseInt(rateLive) > 50 || parseInt(rateLive) < 0) {
            return layer.msg('直播分成比例设置错误，不能大于50或小于0！', {icon: 2});
        }
        if (isNaN(ratePartner)) {
            return layer.msg('合伙人分成比例必需为数字！', {icon: 2});
        }
        if (parseInt(ratePartner) > 20 || parseInt(ratePartner) < 0) {
            return layer.msg('合伙人分成比例设置错误，不能大于20或小于0！', {icon: 2});
        }
        if (isNaN(rateAgent)) {
            return layer.msg('代理分成比例必需为数字！', {icon: 2});
        }
        if (parseInt(rateAgent) > 10 || parseInt(rateAgent) < 0) {
            return layer.msg('代理分成比例设置错误，不能大于10或小于0！', {icon: 2});
        }
        if (isNaN(rateSeller)) {
            return layer.msg('分享者提成比例必需为数字！', {icon: 2});
        }
        if (parseInt(rateSeller) > 20 || parseInt(rateSeller) < 0) {
            return layer.msg('分享者分成比例设置错误，不能大于20或小于0！', {icon: 2});
        }
        if (parseInt(rateMember) > 20 || parseInt(rateMember) < 0) {
            return layer.msg('邀请用户购买会员分成比例设置错误，不能大于20或小于0！', {icon: 2});
        }
        if (isNaN(regCashback)) {
            return layer.msg('注册返现必需为数字！', {icon: 2});
        }
        if (parseInt(regCashback) > 500 || parseInt(regCashback) < 0) {
            return layer.msg('注册返现设置错误，不能大于500或小于0！', {icon: 2});
        }
        if (isNaN(rateMember)) {
            return layer.msg('邀请用户购买会员！', {icon: 2});
        }
        return profileSave();
    }

</script>
</body>
</html>